<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      :inline="true"
      v-show="showSearch"
      label-width="68px"
    >
      <el-form-item label="任务令" prop="po">
        <el-input
          v-model="queryParams.po"
          placeholder="请输入任务令"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button
          type="cyan"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>
    <el-table v-loading="loading" :data="entityRevisionList">
      <!-- <el-table-column type="selection" align="center" /> -->
      <el-table-column
        label="组织ID"
        align="center"
        prop="zorgid"
        :show-overflow-tooltip="true"
        width="100"
      />
      <el-table-column
        label="任务令"
        align="center"
        prop="entityName"
        :show-overflow-tooltip="true"
        width="150"
      />
      <el-table-column
        label="工单号"
        align="center"
        prop="workNumber"
        width="100"
      />
      <el-table-column
        label="项目编码"
        align="center"
        prop="itemNumber"
        width="100"
      />
      <el-table-column
        label="项目版本"
        align="center"
        prop="itemVer"
        :show-overflow-tooltip="true"
        width="100"
      />
      <el-table-column
        label="软件编码"
        align="center"
        prop="softItem"
        :show-overflow-tooltip="true"
        width="100"
      />
      <el-table-column
        label="软件名称"
        align="center"
        prop="softName"
        width="120"
      />
      <el-table-column
        label="软件版本"
        align="center"
        prop="revision"
        width="150"
      />
      <el-table-column
        label="软件位置"
        align="center"
        prop="softLocation"
        :show-overflow-tooltip="true"
        width="100"
      />
      <el-table-column
        label="加工方式"
        align="center"
        prop="modeProcduction"
        :show-overflow-tooltip="true"
        width="100"
        :formatter="modeFormatter"
      />
      <el-table-column
        label="是否需要特殊版本"
        align="center"
        prop="specialRevision"
        :formatter="revisionFormatter"
      />
      <el-table-column
        label="软件层级"
        align="center"
        prop="softLevel"
        :show-overflow-tooltip="true"
        width="100"
      />
      <el-table-column
        label="软件版本是否变更"
        align="center"
        prop="existUpdated"
        :show-overflow-tooltip="true"
        width="150"
        :formatter="updatedFormatter"
      />
      <el-table-column
        label="创建人"
        align="center"
        prop="createBy"
        :show-overflow-tooltip="true"
        width="100"
      />
      <el-table-column
        label="创建时间"
        align="center"
        prop="createDate"
        width="100"
      />
      <el-table-column
        label="更新人"
        align="center"
        prop="updateBy"
        width="100"
      />
      <el-table-column
        label="更新时间"
        align="center"
        prop="updateDate"
        width="100"
      />
      <el-table-column
        label="预留字段"
        align="center"
        prop="segment1"
        width="100"
      />
      <el-table-column
        label="回传的开工时间值，如未回传则为空"
        align="center"
        prop="segment2"
        width="150"
      />
      <el-table-column
        label="回传的回货时间值，如未回传则为空"
        align="center"
        prop="segment3"
        :show-overflow-tooltip="true"
        width="150"
      />
      <el-table-column
        label="软件编码在BOM里面的父项编码"
        align="center"
        prop="segment4"
        :show-overflow-tooltip="true"
        width="150"
      />
      <el-table-column
        label="如是烧录软件，该位置为软件的载体编码"
        align="center"
        prop="segment5"
        :show-overflow-tooltip="true"
        width="150"
      />
    </el-table>

    <!-- <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
            @pagination="getList" /> -->
  </div>
</template>

<script>
import { getEntityRevision } from "@/api/ems/entityRevision";

export default {
  name: "BarcodeAttribute",
  data() {
    return {
      // 遮罩层
      loading: false,

      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,

      entityRevisionList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        po: null,
      },
      // 表单参数
      form: {},
    };
  },

  methods: {
    /** 查询产品条码属性列表 */
    getList() {
      if (!this.queryParams.po) {
        return this.$message({ message: "请输入任务令", type: "error" });
      }
      this.loading = true;
      getEntityRevision(this.queryParams.po)
        .then((response) => {
          this.entityRevisionList = response.data;
          // this.total = response.total;
          this.loading = false;
        })
        .catch(() => {
          this.loading = false;
        });
    },
    updatedFormatter(val) {
      if (val.existUpdated == "Y") {
        return "是";
      } else {
        return "否";
      }
    },
    revisionFormatter(val) {
      if (val.specialRevision == "1") {
        return "是";
      } else {
        return "否";
      }
    },
    modeFormatter(val) {
      switch (val.modeProcduction) {
        case "0":
          return "烧录软件";
        case "1":
          return "加载软件";
        default:
          return "";
      }
    },
    // 表单重置
    reset() {
      this.form = {
        po: "",
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
    },
  },
};
</script>